﻿package com.msjt.service.impl;

import java.util.List;

import javax.annotation.Resource;

import com.msjt.dao.NewsDAO;
import com.msjt.entity.News;
import com.msjt.service.INewsService;
/**
 * name:NewsService
 * function:新闻信息service
 * author: kw
 * time:2013.8.26
 */
public class NewsService implements INewsService {
	@Resource
	private NewsDAO newsDao;

	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#setNewsDao(com.msjt.dao.NewsDAO)
	 */
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#setNewsDao(com.msjt.dao.NewsDAO)
	 */
	public void setNewsDao(NewsDAO newsDao) {
		this.newsDao = newsDao;
	}
	//加载新闻列表，分页处理
	
	//添加新闻
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#addNews(com.msjt.entity.News)
	 */
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#addNews(com.msjt.entity.News)
	 */
	public boolean addNews(News news){
		return this.newsDao.addNews(news);
	}
	//修改新闻
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#updatedNews(com.msjt.entity.News)
	 */
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#updatedNews(com.msjt.entity.News)
	 */
	public boolean updatedNews(News news){
		return this.newsDao.updateNews(news);
	}
	//根据ID查看新闻
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#getNewsById(com.msjt.entity.News)
	 */
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#getNewsById(com.msjt.entity.News)
	 */
	public News getNewsById(News news){
		return this.newsDao.getNewsInfo(news);
	}
	//查找前5条未置顶的新闻
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#getNewsTopFive()
	 */
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#getNewsTopFive()
	 */
	public List<News> getNewsTopFive(){
		return this.newsDao.findFiveNewsTime();
	}
	//查找前6条置顶新闻
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#getNewsTopSix()
	 */
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#getNewsTopSix()
	 */
	public List<News> getNewsTopSix(){
		return this.newsDao.findSixNewsTopTime();
	}
	//增加新闻次数
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#updateClickNum(com.msjt.entity.News)
	 */
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#updateClickNum(com.msjt.entity.News)
	 */
	public boolean updateClickNum(News news){
		return this.newsDao.updateClickNum(news);
	}
	//新闻置顶
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#updateTop(com.msjt.entity.News)
	 */
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#updateTop(com.msjt.entity.News)
	 */
	public boolean updateTop(News news){
		return this.newsDao.clickTop(news);
	}
	//删除新闻
	/* (non-Javadoc)
	 * @see com.msjt.service.impl.INewsService#deleteNews(com.msjt.entity.News)
	 */
	public boolean deleteNews(News news){
		return this.newsDao.deleteNews(news);
	}
	

	public Integer getNewsCount() {
		return this.newsDao.getNewsCount();
	}

	public List<News> getNewsMore(int pageIndex,int pageSize) {
		return this.newsDao.getNewsMore(pageIndex, pageSize);
	}

	public List<News> getNewsAdmin(int pageIndex,int pageSize) {
		return this.newsDao.getNewsAdmin(pageIndex, pageSize);
	}

	public Integer getNewsCount(News news) {
		// TODO Auto-generated method stub
		return this.newsDao.getNewsCount(news);
	}

	public List<News> selectNewsLike(News news, int pageIndex, int pageSize) {
		// TODO Auto-generated method stub
		return this.newsDao.selectNewsLike(news, pageIndex, pageSize);
	}

	public boolean deleteMore(String idString) {
		// TODO Auto-generated method stub
		return this.newsDao.deleteMore(idString);
	}
	
}	
